﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Magic.Framework.OQL;
using Antlr.Runtime;
using Magic.Framework.OQL.Expressions;
using System.Diagnostics;

namespace Ddbs.QE.Parser.Front
{
    class Program
    {
        
        public static void Main()
        {
            Serialization.Conf.test();
            Serialization.Conf conf = new Serialization.Conf();
            conf = Serialization.Conf.DeSerializeConf("trial.xml");
            Serialization.ConfHelper confHelper = new Serialization.ConfHelper(conf);
            string s = "selecT id,book.*,name from book where not (id>1 and not ((id<=16) or (id>9)));\n";
            SQLLexer lex = new SQLLexer(new CaseInsensitiveStringStream(s));
            CommonTokenStream tokens = new CommonTokenStream(lex);
            SQLParser parser = new SQLParser(tokens);
            //parser.TreeAdaptor = new TreeFactory();
            SQLParser.start_return statements = parser.start();

            List<SQLContext> contexts = SQLParserHeler.extractSQLContexts(statements);
            foreach (SQLContext context in contexts)
            {
                Debug.Assert(context.Columns != null && context.Tables != null);
                SQLParserHeler.printContext(context);
                if (!Factory.SQLSemanticer.check(context, conf))
                {
                    Console.WriteLine("semantic check fail!");
                }
                //AlgebraTree tree = new AlgebraTree(context);
                
            }
            
           
        }
    }
}
